<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$("#dialog").dialog({autoOpen:false,modal:true});
	$(".copy").click(function(){
		var copy_id = $(this).parent().prev().prev().prev().prev().prev().text();
		$("#copy_id").val(copy_id);
		$("#dialog").dialog("open");
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get" action="">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>所属基板</th>
		<td>
			<select name="base_id">
			<option value="">请选择</option>
			<?foreach ($base as $b):?>
			<option value="<?=$b['id']?>" <?if (isset($_GET['base_id']) && $_GET['base_id'] == $b['id'])echo "selected='selected'"?>><?=$b['name']?></option>
			<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>店铺</th>
		<td>
			<select name="shop_id">
			<option value="">请选择</option>
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id'])echo "selected='selected'"?>><?=$s['name']?></option>
			<?endforeach;?>
		</select>
		</td>
	</tr>
	<tr>
		<th>名称</th>
		<td><input type="text" name="template_name" value="<?=isset($_GET['template_name']) ? $_GET['template_name'] : '';?>" /></td>
	</tr>
	<tr>
		<th>Path</th>
		<td><input type="text" name="path" value="<?=isset($_GET['path']) ? $_GET['path'] : '';?>" /></td>
	</tr>
	<tr>
		<th></th>
		<td><input type="submit" class="button" value="查询" /></td>
	</tr>
</table>
</form>
</fieldset>
<table class="list_table" width="100%">
<tr>
	<th>ID</th>
	<th>模板名称</th>
	<th>所属基板</th>
	<th>所属店铺</th>
	<th>path</th>
	<th>操作</th>
</tr>
<?foreach ($template as $t):?>
<tr>
	<td><?=$t['id']?></td>
	<td><a class="detail" href="<?=url('Online::EbayTemplate/TemplateDetail', array('id' => $t['id']))?>"><?=$t['name']?></a></td>
	<td><?=$t['base_name']?></td>
	<td><?=$t['shop_name']?></td>
	<td><?=$t['path']?></td>
	<td>
		<a href="<?=url('Online::EbayTemplate/TemplatePreview', array('id' => $t['id'], 'type' => 'preview'))?>" target="_blank">本地预览</a>
		<a href="<?=url('Online::EbayTemplate/TemplatePreview', array('id' => $t['id'], 'type' => 'outside'))?>" target="_blank">外网预览</a>
		<a href="<?=url('Online::EbayTemplate/TemplatePreview', array('id' => $t['id'], 'type' => 'outside', 'getcode' => true))?>" target="_blank">获取代码</a>
		<a href="<?=url('Online::EbayTemplate/SynOutside', array('id' => $t['id']))?>" onclick="if(!confirm('确定本地预览没问题，同步到外网？')) return false;">同步外网</a>
		<a href="<?=url('Online::EbayTemplate/TemplateEdit', array('id' => $t['id']))?>">编辑</a>
		<a class="copy">复制</a>
	</td>
</tr>
<?endforeach;?>
</table>
<div id="dialog" title="复制模板">
<form method="post" action="<?=url('Online::EbayTemplate/TemplateCopy')?>">
<table class="form_table">
<tr>
	<th>所属店铺</th>
	<td>
		<select name="shop_id" dataType="Require" msg=" 请选择所属店铺" >
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>"><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>新模板名称</th>
	<td><input type="text" name="template_name" /></td>
</tr>
<tr>
	<th><input type="hidden" name="copy_id" id="copy_id" /></th>
	<td><input type="submit" value="确认复制" class="button" /></td>
</tr>
</table>
</form>
</div>
<?=$page;?>
<?php $this->_endblock();?>